<?php

$info=[
    'wechat_key'=>$_SERVER["DOCUMENT_ROOT"]."/cert/apiclient_key.pem",
    'wechat_mchid'=>'1710163332',
    'wechat_cert'=>$_SERVER["DOCUMENT_ROOT"] ."/cert/apiclient_cert.pem"
];
$time = time();
$nonce_str = md5(mt_rand(10000000, 99999999) . time() . mt_rand(10000000, 99999999));
$nonce_str0 = md5(mt_rand(10000000, 99999999) . time() . mt_rand(10000000, 99999999));

openssl_sign("GET\n/v3/certificates\n" . $time . "\n" . $nonce_str . "\n" . "\n", $sign, openssl_pkey_get_private(file_get_contents($info["wechat_key"])), 'sha256WithRSAEncryption');

$a='Authorization: WECHATPAY2-SHA256-RSA2048 mchid="' . $info["wechat_mchid"] . '",nonce_str="' . $nonce_str . '",signature="' . base64_encode($sign) . '",timestamp="' . $time . '",serial_no="' . (openssl_x509_parse(openssl_x509_read(file_get_contents($info["wechat_cert"]))))["serialNumberHex"] . '"';

echo $a;